import request from '@/utils/request'

// 注册端口
export const register = ({ username, password, repassword }) => {
  return request.post('/api/reg', {
    username,
    password,
    repassword
  })
}
// // 获取左侧侧边栏列表
export const getMenuList = (obj) => {
  return request.get('/my/menus', {
    params: {
      obj
    }
  })
}
// 登录端口
export const login = ({ username, password }) => {
  return request.post('/api/login', {
    username,
    password
  })
}
// 增加-文章分类
export const addArticleClass = ({ cate_name, cate_alias }) => {
  return request.post('/my/cate/add', {
    cate_name, cate_alias
  })
}
// 获取-文章分类
export const getArticleClass = ({ cate_name, cate_alias }) => {
  return request.get('/my/cate/list', {
    data: {
      cate_name, cate_alias
    }
  })
}
// 删除-文章分类
export const delArticleClass = (id) => {
  return request.delete('/my/cate/del', {
    params: {
      id
    }
  })
}
// 获取-文章分类单个详情
export const getArticleDetail = (id) => {
  return request.get('/my/cate/info', {
    params: {
      id
    }
  })
}
// 修改提交更新-文章分类单个详情
export const updateArticle = data => {
  return request.put('/my/cate/info', data)
}
// 获取-文章列表!!
export const getArticleList = ({ pagenum, pagesize }) => {
  return request.get('/my/article/list', {
    params: {
      pagenum,
      pagesize
    }
  })
}
// 添加文章
export const addArticle = obj => {
  return request.post('/my/article/add', obj)
}

/**
 * 获取-用户基础资料
 * @returns Promise对象
 */
export const getUserInfoAPI = () => {
  return request({
    url: '/my/userinfo'
  })
}

/**
 * 获取-侧边栏菜单数据
 * @returns Promise对象
 */
export const getMenusAPI = () => {
  return request({
    url: '/my/menus'
  })
}
